```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HotSpot JVM 垃圾收集机制详解</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .transition-all {
            transition: all 0.3s ease;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 0.8;
            margin: 0.2em 0.1em 0 0;
            color: #4f46e5;
            font-weight: bold;
        }
    </style>
</head>
<body class="min-h-screen flex flex-col">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">HotSpot JVM 垃圾收集机制</h1>
            <p class="text-xl md:text-2xl text-indigo-100 max-w-3xl mx-auto mb-8">深入解析不同条件下的垃圾收集触发策略与优化之道</p>
            <div class="flex justify-center space-x-4">
                <a href="#minor-gc" class="bg-white text-indigo-600 hover:bg-indigo-50 px-6 py-3 rounded-lg font-medium transition-all">新生代GC</a>
                <a href="#major-gc" class="bg-indigo-700 hover:bg-indigo-600 text-white px-6 py-3 rounded-lg font-medium transition-all">老年代GC</a>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="flex-grow container mx-auto px-4 sm:px-6 lg:px-8 py-12 max-w-5xl">
        <!-- Intro Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <p class="drop-cap text-lg md:text-xl text-gray-700">HotSpot JVM 中的垃圾收集器在不同条件下触发垃圾收集，以优化内存使用和应用程序性能。新生代垃圾收集主要基于 Eden 区和 Survivor 区的状态，而老年代垃圾收集则根据老年代的空间使用情况和内存压力进行触发。</p>
            </div>
        </section>

        <!-- GC Overview Visualization -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-6">
                <h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-2">垃圾收集器概览</h2>
                <div class="mermaid">
                    graph TD
                    A[垃圾收集器] --> B[新生代GC]
                    A --> C[老年代GC]
                    B --> D[Serial GC]
                    B --> E[Parallel GC]
                    B --> F[G1 GC]
                    C --> G[Serial Old]
                    C --> H[Parallel Old]
                    C --> I[CMS]
                    C --> J[G1 GC]
                    C --> K[ZGC]
                    C --> L[Shenandoah GC]
                </div>
            </div>
        </section>

        <!-- Minor GC Section -->
        <section id="minor-gc" class="mb-16">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="bg-indigo-50 px-6 py-4 border-b border-indigo-100">
                    <h2 class="text-2xl font-bold text-indigo-700 flex items-center">
                        <i class="fas fa-baby-carriage mr-3"></i>
                        新生代垃圾收集（Minor GC）
                    </h2>
                </div>
                <div class="p-6">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2">触发条件：</h3>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <!-- Eden区满 -->
                        <div class="bg-indigo-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-indigo-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-fill-drip text-indigo-600"></i>
                                </div>
                                <h4 class="font-bold text-indigo-700">Eden 区满</h4>
                            </div>
                            <p class="text-gray-700">当新生代的 Eden 区满时，会触发新生代垃圾收集。此时，所有活动的对象将会从 Eden 区转移到 Survivor 区，未活动的对象将被清除。</p>
                        </div>
                        
                        <!-- Survivor区满 -->
                        <div class="bg-indigo-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-indigo-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-exchange-alt text-indigo-600"></i>
                                </div>
                                <h4 class="font-bold text-indigo-700">Survivor 区满</h4>
                            </div>
                            <p class="text-gray-700">如果 Survivor 区（S0 或 S1）也满了，会触发 Minor GC，将部分对象晋升到老年代，或将对象移动到另一 Survivor 区。</p>
                        </div>
                    </div>
                    
                    <!-- Visualization -->
                    <div class="mt-8">
                        <div class="mermaid">
                            graph LR
                            Eden[Eden区满] -->|触发| MinorGC[Minor GC]
                            Survivor[Survivor区满] -->|触发| MinorGC
                            MinorGC -->|活动对象| S0[Survivor 0]
                            MinorGC -->|活动对象| S1[Survivor 1]
                            MinorGC -->|不活动对象| X[清除]
                            S0 -->|空间不足| Old[老年代]
                            S1 -->|空间不足| Old
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Major GC Section -->
        <section id="major-gc" class="mb-16">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="bg-purple-50 px-6 py-4 border-b border-purple-100">
                    <h2 class="text-2xl font-bold text-purple-700 flex items-center">
                        <i class="fas fa-tree mr-3"></i>
                        老年代垃圾收集（Major GC 或 Full GC）
                    </h2>
                </div>
                <div class="p-6">
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2">触发条件：</h3>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <!-- 老年代满 -->
                        <div class="bg-purple-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-purple-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-box-open text-purple-600"></i>
                                </div>
                                <h4 class="font-bold text-purple-700">老年代满</h4>
                            </div>
                            <p class="text-gray-700">当老年代的内存满时，会触发老年代垃圾收集（Full GC）。此时，整个堆会进行垃圾回收，包括新生代和老年代。</p>
                        </div>
                        
                        <!-- YGC后老年代对象晋升 -->
                        <div class="bg-purple-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-purple-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-level-up-alt text-purple-600"></i>
                                </div>
                                <h4 class="font-bold text-purple-700">YGC 后老年代对象晋升</h4>
                            </div>
                            <p class="text-gray-700">当新生代的垃圾收集（Minor GC）后，有大量对象晋升到老年代，并且老年代的空间不足时，会触发 Full GC。</p>
                        </div>
                        
                        <!-- 显式调用 -->
                        <div class="bg-purple-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-purple-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-hand-point-up text-purple-600"></i>
                                </div>
                                <h4 class="font-bold text-purple-700">显式调用</h4>
                            </div>
                            <p class="text-gray-700">通过 `System.gc()` 或 `Runtime.gc()` 等 API 显式调用垃圾收集器时，会触发 Full GC。虽然不建议在生产环境中频繁使用这些方法，但它们可以用于测试和调试。</p>
                        </div>
                        
                        <!-- 内存不足 -->
                        <div class="bg-purple-50 rounded-lg p-5 card-hover transition-all">
                            <div class="flex items-center mb-3">
                                <div class="bg-purple-100 w-10 h-10 rounded-full flex items-center justify-center mr-3">
                                    <i class="fas fa-exclamation-triangle text-purple-600"></i>
                                </div>
                                <h4 class="font-bold text-purple-700">内存不足</h4>
                            </div>
                            <p class="text-gray-700">如果 JVM 运行时发现内存不足或无法分配对象时，也会触发 Full GC，以释放更多的空间。</p>
                        </div>
                    </div>
                    
                    <!-- Visualization -->
                    <div class="mt-8">
                        <div class="mermaid">
                            flowchart TD
                            A[老年代满] -->|触发| FullGC[Full GC]
                            B[YGC后老年代对象晋升] -->|触发| FullGC
                            C[显式调用System.gc] -->|触发| FullGC
                            D[内存不足] -->|触发| FullGC
                            FullGC --> E[回收新生代]
                            FullGC --> F[回收老年代]
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- GC Specific Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="bg-blue-50 px-6 py-4 border-b border-blue-100">
                    <h2 class="text-2xl font-bold text-blue-700 flex items-center">
                        <i class="fas fa-cogs mr-3"></i>
                        垃圾收集器特定的触发条件
                    </h2>
                </div>
                <div class="p-6">
                    <!-- Serial & Parallel GC -->
                    <div class="mb-10">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2 flex items-center">
                            <i class="fas fa-stream mr-2 text-blue-500"></i>
                            Serial GC 和 Parallel GC
                        </h3>
                        <div class="grid md:grid-cols-2 gap-6">
                            <div class="bg-blue-50 rounded-lg p-5">
                                <h4 class="font-bold text-blue-700 mb-2">新生代回收</h4>
                                <p class="text-gray-700">在使用 Serial GC 或 Parallel GC 时，新生代的垃圾收集（Minor GC）会在 Eden 区满时触发。</p>
                            </div>
                            <div class="bg-blue-50 rounded-lg p-5">
                                <h4 class="font-bold text-blue-700 mb-2">老年代回收</h4>
                                <p class="text-gray-700">在使用 Parallel GC 时，老年代的垃圾收集（Full GC）会在老年代满时触发。</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- CMS -->
                    <div class="mb-10">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2 flex items-center">
                            <i class="fas fa-bolt mr-2 text-green-500"></i>
                            Concurrent Mark-Sweep (CMS)
                        </h3>
                        <div class="grid md:grid-cols-3 gap-6">
                            <div class="bg-green-50 rounded-lg p-5">
                                <h4 class="font-bold text-green-700 mb-2">老年代的高水位</h4>
                                <p class="text-gray-700">CMS 会在老年代的高水位触发垃圾收集。</p>
                            </div>
                            <div class="bg-green-50 rounded-lg p-5">
                                <h4 class="font-bold text-green-700 mb-2">Promoted Objects</h4>
                                <p class="text-gray-700">当对象从新生代晋升到老年代时，如果老年代没有足够空间，CMS 会触发 Full GC。</p>
                            </div>
                            <div class="bg-green-50 rounded-lg p-5">
                                <h4 class="font-bold text-green-700 mb-2">CMS 触发器</h4>
                                <p class="text-gray-700">CMS 还包括多种触发机制，如初始标记、并发标记和重新标记，以确保低延迟。</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- G1 -->
                    <div class="mb-10">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2 flex items-center">
                            <i class="fas fa-chess-board mr-2 text-yellow-500"></i>
                            Garbage-First (G1)
                        </h3>
                        <div class="grid md:grid-cols-3 gap-6">
                            <div class="bg-yellow-50 rounded-lg p-5">
                                <h4 class="font-bold text-yellow-700 mb-2">设置的回收目标</h4>
                                <p class="text-gray-700">G1 垃圾收集器会根据设置的回收目标（例如，目标停顿时间）来触发垃圾收集。</p>
                            </div>
                            <div class="bg-yellow-50 rounded-lg p-5">
                                <h4 class="font-bold text-yellow-700 mb-2">新生代满</h4>
                                <p class="text-gray-700">当新生代（Eden 区）满时，会触发 G1 垃圾收集。</p>
                            </div>
                            <div class="bg-yellow-50 rounded-lg p-5">
                                <h4 class="font-bold text-yellow-700 mb-2">老年代压力</h4>
                                <p class="text-gray-700">当老年代的空间不足时，G1 也会触发 Full GC，以处理老年代的内存回收。</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- ZGC & Shenandoah -->
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2 flex items-center">
                            <i class="fas fa-tachometer-alt mr-2 text-red-500"></i>
                            ZGC 和 Shenandoah GC
                        </h3>
                        <div class="bg-red-50 rounded-lg p-5 max-w-2xl">
                            <h4 class="font-bold text-red-700 mb-2">高延迟触发</h4>
                            <p class="text-gray-700">ZGC 和 Shenandoah GC 设计用于低延迟环境，它们会在内存压力高时触发垃圾收集，以确保尽可能减少停顿时间。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-semibold text-white">技术小馆</h3>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-indigo-100 transition-colors duration-200">
                        <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="mt-6 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. All rights reserved.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```